package com.lf.web.action.system;

import com.lf.data.Cluster;
import com.lf.data.ClusterUtil;
import com.lf.data.search.Field;
import com.lf.data.search.Sort;
import com.lf.web.service.system.webnode.WebNode;
import com.lf.web.service.system.webnode.WebNodeDAO;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.log4j.Logger;

import java.util.List;

public class ChannelMenuService extends ActionSupport {

    private static final Logger LOGGER = Logger.getLogger(ChannelMenuService.class);
    private WebNodeDAO channeldao;
    private List<Cluster> channels = null;

    public void setChanneldao(WebNodeDAO channeldao) {
        this.channeldao = channeldao;
    }

    public String execute() {
        Field field = new Field();
        field.include(WebNode.NAME, WebNode.PARENT_ID);
        Sort sort = new Sort();
        sort.desc(WebNode.INDEX);
        channels = channeldao.find(null, field, sort);
        return SUCCESS;
    }

    public List<Cluster> getChannels() {
        return channels;
    }

    public Cluster getCheck() {
        return ClusterUtil.getCheck(WebNode.class);
    }
}
